<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>提交课题</title>
<%@ include file="/module/js.jsp"%>
</head>
<body>
	<form action="#" name="Form" id="Form" method="post">
		<input type="hidden" name="idList" id="idList"/>
		<input type="hidden" id="bodyData" name="bodyData" value=""/>
		<input type="hidden" name="type" id="type" value="${type}"/>
		<table cellpadding="1" cellspacing="1" border="0">
			 <c:if test="${_login_user_type==2}">
			<tr>
				<td><input type="button" id="btnQuery" value="查询"
					class="inputButton" /></td>
				<td>
				<kl:permission permisstionList="${permisstionList}"
                    currentUser="${_login_console_user}"
                    currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_TJKT\")%>" key="add"> 
				<input type="button" id="btnAdd" value="添 加"
					class="inputButton" />
				</kl:permission>	
			    </td>
				<td>
				<kl:permission permisstionList="${permisstionList}"
                    currentUser="${_login_console_user}"
                    currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_TJKT\")%>" key="delete">
				<input type="button" id="btnDelete" value="删除"
					class="inputButton" />
			    </kl:permission>
			    </td>
				<td><input type="button" id="btnExport" value="导出"
					 class="inputButton"/></td>
			</tr>
		  </c:if>
		</table>
	   <table cellpadding="1" cellspacing="1" style="width:80%;">
			<tr>
				<td>标题：</td>
				<td>
				<input type="text" name="subject" id="subject"  autocomplete="off" class="inputText2" /></td>
				<td>类别：</td>
				<td>
				<input type="text" name="kTLB" id="kTLB"   autocomplete="off" class="inputText2" /></td>
				<td>提交日期:</td>
				<td>
				   从<input type="text" name="beginTime" id="beginTime"   autocomplete="off" 
					   class="Wdate inputText2"
					   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
				 &nbsp;到<input type="text" name="endTime" id="endTime"   autocomplete="off" 
				   class="Wdate inputText2"
					   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/> 
				</td>
			</tr>
			<tr>
			   <td>进度:</td>
			   <td colspan="6">
				   <input name="curStep" id="curStep0" type="radio" checked="checked" value="0"/> <label for="curStep0">全部</label>
				   <input name="curStep" id="curStep1" type="radio" value="1"/><label for="curStep1">填报课题</label> </input>
				   <input name="curStep" id="curStep2" type="radio" value="2"/><label for="curStep2">开题报告</label>
				   <input name="curStep" id="curStep3" type="radio" value="3"/><label for="curStep3">中期报告</label>
				   <input name="curStep" id="curStep4" type="radio" value="4"/><label for="curStep4">结题报告</label>
				   <input name="curStep" id="curStep5" type="radio" value="5"/><label for="curStep5">研究过程及附件</label>
			   </td>
			</tr>
		</table>	
	<table id="dg"  style="width:100%;"
		data-options="pagination:true,collapsible:true,url:'${basePath}/researchProject/getListData',method:'post',remoteSort:true">
		<thead>
			<tr>
				<th data-options="field:'kTID',checkbox:true,width:60,align:'center'"></th>
			    <th data-options="field:'subject',sortable:true,nowrap:true,width:110,align:'center',formatter:formater">标题</th>
				<th data-options="field:'kTLB',sortable:true,nowrap:true,width:200,align:'center'">类别</th>
			    <th data-options="field:'kTSJ',sortable:true,nowrap:true,width:300,align:'center'">时间</th>
				<th data-options="field:'curStep',sortable:true,nowrap:true,width:250,align:'center',formatter:curStep">进度</th>
			    <th data-options="field:'createTime',sortable:true,nowrap:true,width:300,align:'center',formatter:formatDate">提交时间</th>
			</tr>
		</thead>
	</table>
	</form>
    <script>
    //,formatter:formater
    function formater(value, row, index) {
    	var type = $('#type').val();
	       return "<a href='${basePath}/researchProject/premodify?kTID=" + row.kTID + "&type=1'>" + row.subject + "</a>";
	  } 
	    function formatDate(value){
	    	var date=new Date(value);
			var y = date.getFullYear();
			var m = date.getMonth()+ 1;
			var d = date.getDate();
			var h= date.getHours();       //获取当前小时数(0-23)
			var mm= date.getMinutes();     //获取当前分钟数(0-59)
			var s= date.getSeconds();     //获取当前秒数(0-59)
			return y +'-'+(m <10?('0'+ m):m)+'-'+(d <10?('0'+ d):d)+' :'+(h <10?('0'+ h):h)+':'+(mm <10?('0'+ mm):mm)+':'+(s <10?('0'+ s):s);
		}
    
		//格式化进度
		 function curStep(val,row,index){
			 return row.researchProjectStep.stepName;
		}	 
     </script>
		 <script type="text/javascript">
			$(document).ready(function() {
	            $('#dg').datagrid({
				   rowStyler: function(index,row){
				   },
				   onLoadSuccess : function(data) {//加载完毕后获取所有的checkbox遍历
						if (data.rows.length > 0) {
						}
					},
				});
					// 添加				
				$('#btnAdd').click(function() {
					   window.location.href = "${basePath}/researchProject/preadd";
				});					
					//查询
				$('#btnQuery').click(function() {
					$('#dg').datagrid('load',{
						subject: $('#subject').val(),
						kTLB: $('#kTLB').val(),
						curStep: $('input[name="curStep"]:checked').val(),
						beginTime: $('#beginTime').val(),
						endTime: $('#endTime').val(),
					});
				});
					// 删除
				$('#btnDelete').click(function() {
				    	$("#idList").val("");
					    var count = 0;
						var idList = new Array();
					    var sels = $("#dg").datagrid("getSelections");
				    	for(var i in sels){
				    		idList.push(sels[i].kTID);
				    		count++;
				    	}
						if (count == 0) {
							layer.alert("您至少选择一条删除记录信息", {icon: 3});
							return false;
						}else{
							  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
								    $("#idList").val(idList);
								    document.Form.action = "${basePath}/researchProject/delete";
									document.Form.submit();
							  },function(index){
									layer.close(index);
							  });
						}
					});
		     	});
				 if("${msg}"!=""){
				       layer.alert("${msg}", {icon: 6});
				 } 
				$('#btnExport').on('click', function(){
					   layer.confirm("您确定要导出吗?", function(index){
						    document.Form.action = "${basePath}/researchProject/export_df";
							document.Form.submit();
							layer.close(index);
	            		 });
					});
	</script>
</body>
</html>
